#!/bin/bash
set -e

cd ${JM_SHARE_DIR}
# svn checkout拉取代码
if [[ -z ${JIANMU_CODE_VERSION} ]]; then
  svn checkout ${JIANMU_CODE_URL} --username ${JIANMU_SVN_USERNAME} --password ${JIANMU_SVN_PASSWORD}
else
  svn checkout ${JIANMU_CODE_URL} -r${JIANMU_CODE_VERSION} --username ${JIANMU_SVN_USERNAME} --password ${JIANMU_SVN_PASSWORD}
fi

engineering_name=$(echo ${JIANMU_CODE_URL##*/})
getdate=$(date +"%Y%m%d.%H%M")
cd ${engineering_name}
svnrevision=$(svn info --show-item revision)
echo "resultFile:"
echo -e "{\"code_path\": \"${JM_SHARE_DIR}/${engineering_name}\",\"code_revision\": \"${svnrevision}\",\"code_checkouttime\": \"${getdate}\"}" > resultFile
mv resultFile /usr

cat /usr/resultFile